/// @tags: Block Division
#include <algorithm>
#include <cctype>
#include <cstdio>

template <typename T>
inline T &read(T &x) {
  x = 0;
  bool f = false;
  short ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = true;
    ch = getchar();
  }
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ '0'), ch = getchar();
  if (f) x = -x;
  return x;
}

const int N = 5e4 + 5, bit = 17, blk = 250;

int n, b[N], c[N], dep[N], fa[bit][N], a[N], sum[N];
int e_cnt, heads[N];
int s[blk][N];

struct Edge {
  int v, nxt;
} e[N << 1];

inline void add(int u, int v) {
  e[++e_cnt].v = v, e[e_cnt].nxt = heads[u], heads[u] = e_cnt;
}

void dfs(int u) {
  sum[u] += a[u];
  for (int i = 1; i < bit; ++i) fa[i][u] = fa[i - 1][fa[i - 1][u]];
  for (int i = heads[u], v; i; i = e[i].nxt)
    if (!dep[v = e[i].v]) {
      dep[v] = dep[u] + 1, sum[v] = sum[u], fa[0][v] = u;
      dfs(v);
    }
}

inline int getlca(int x, int y) {
  if (dep[x] < dep[y]) std::swap(x, y);
  for (int i = bit - 1; ~i; --i)
    if (dep[fa[i][x]] >= dep[y]) x = fa[i][x];
  if (x == y) return x;
  for (int i = bit - 1; ~i; --i)
    if (fa[i][x] != fa[i][y]) x = fa[i][x], y = fa[i][y];
  return fa[0][x];
}

inline int getfa(int u, int x) {
  for (int i = bit - 1; ~i; --i)
    if ((x >> i) & 1) u = fa[i][u];
  return u;
}

void dfs2(int u) {
  int ffa = fa[0][u];
  for (int i = 2; i < blk; ++i) {
    ffa = fa[0][ffa];
    s[i][u] = s[i][ffa] + a[u];
  }
  for (int i = heads[u], v; i; i = e[i].nxt)
    if (dep[u] < dep[v = e[i].v]) dfs2(v);
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen64("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen64("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("P3591 [POI2015]ODW.in", "r", stdin);
  freopen("P3591 [POI2015]ODW.out", "w", stdout);
#endif
#endif

  read(n);
  for (int i = 1; i <= n; ++i) read(a[i]);
  for (int i = 1, u, v; i < n; ++i) {
    read(u), read(v);
    add(u, v), add(v, u);
  }
  for (int i = 1; i <= n; ++i) read(b[i]);
  for (int i = 1; i < n; ++i) read(c[i]);
  dfs(dep[1] = 1);
  dfs2(1);
  for (int i = 1; i < n; ++i) {
    int u = b[i], v = b[i + 1], c = ::c[i];
    int lca = getlca(u, v);
    if (c == 1) printf("%d\n", sum[u] + sum[v] - sum[lca] - sum[fa[0][lca]]);
    else if (c < blk) {
      int ans = s[c][u], di = (dep[u] - dep[lca]) % c;
      if (di == 0) di = c;
      for (int i = bit - 1; ~i; --i)
        if (dep[fa[i][u]] - dep[lca] >= di) u = fa[i][u];
      ans += a[u] - s[c][u];
      if (dep[u] + dep[v] - (dep[lca] << 1) >= c) {
        di = c - dep[u] + dep[lca];
        u = v;
        for (int i = bit - 1; ~i; --i)
          if (dep[fa[i][u]] - dep[lca] >= di) u = fa[i][u];
        di = (dep[v] - dep[u]) % c;
        if (di != 0) ans += a[v];
        v = getfa(v, di);
        ans += s[c][v] - s[c][u] + a[u];
      } else
        ans += a[v];
      printf("%d\n", ans);
    } else {
      int ans = 0;
      while (dep[u] - dep[lca] > c) {
        ans += a[u];
        u = getfa(u, c);
      }
      ans += a[u];
      if (dep[u] + dep[v] - (dep[lca] << 1) >= c) {
        int di = c - dep[u] + dep[lca];
        u = v;
        for (int i = bit - 1; ~i; --i)
          if (dep[fa[i][u]] - dep[lca] >= di) u = fa[i][u];
        di = (dep[v] - dep[u]) % c;
        if (di != 0) ans += a[v];
        v = getfa(v, di);
        while (dep[v] - dep[u] >= c) {
          ans += a[v];
          v = getfa(v, c);
        }
        ans += a[v];
      } else
        ans += a[v];
      printf("%d\n", ans);
    }
  }
  return 0;
}